/*
 * LogisticsInfoItem.java
 * business
 *
 * Created by ChenTao on 2017/2/21.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yidiandao.business.R;

/** 确认订单页面-支付方式/配送方式对应的一个单选Item */
public class LogisticsInfoItem extends LinearLayout {

    private View mViewLogisticsLineTop;
    private View mViewLogisticsCircle;
    private View mViewLogisticsLineBottom;
    private TextView mTvLogisticsInfo;
    private TextView mTvLogisticsTime;

    public LogisticsInfoItem(Context context) {
        this(context, null);
    }

    public LogisticsInfoItem(Context context, AttributeSet attrs) {
        super(context, attrs);
        View root = LayoutInflater.from(context).inflate(R.layout.item_logistics, this, true);
        mViewLogisticsLineTop = root.findViewById(R.id.view_logistics_line_top);
        mViewLogisticsCircle = root.findViewById(R.id.view_logistics_circle);
        mViewLogisticsLineBottom = root.findViewById(R.id.view_logistics_line_bottom);
        mTvLogisticsInfo = (TextView) root.findViewById(R.id.tv_logistics_info);
        mTvLogisticsTime = (TextView) root.findViewById(R.id.tv_logistics_time);
    }

    /** 第一条数据 */
    public void setFirstItem() {
        mViewLogisticsLineTop.setVisibility(INVISIBLE);
        mViewLogisticsLineBottom.setVisibility(VISIBLE);
        mViewLogisticsCircle.setBackgroundResource(R.drawable.bg_circle_red);
        mTvLogisticsInfo.setEnabled(true);
        mTvLogisticsTime.setEnabled(true);
    }

    /** 最后一条数据 */
    public void setLastItem() {
        mViewLogisticsLineBottom.setVisibility(INVISIBLE);
        mViewLogisticsLineTop.setVisibility(VISIBLE);
        mViewLogisticsCircle.setBackgroundResource(R.drawable.bg_circle_gray);
        mTvLogisticsInfo.setEnabled(false);
        mTvLogisticsTime.setEnabled(false);
    }

    /** 只有一条数据 */
    public void setOneItem() {
        mViewLogisticsLineBottom.setVisibility(INVISIBLE);
        mViewLogisticsLineTop.setVisibility(INVISIBLE);
        mViewLogisticsCircle.setBackgroundResource(R.drawable.bg_circle_red);
        mTvLogisticsInfo.setEnabled(true);
        mTvLogisticsTime.setEnabled(true);
    }

    /** 普通数据 */
    public void setNormal() {
        mViewLogisticsLineBottom.setVisibility(VISIBLE);
        mViewLogisticsLineTop.setVisibility(VISIBLE);
        mViewLogisticsCircle.setBackgroundResource(R.drawable.bg_circle_gray);
        mTvLogisticsInfo.setEnabled(false);
        mTvLogisticsTime.setEnabled(false);
    }

    /** 设置物流信息 */
    public void setTitle(String info) {
        mTvLogisticsInfo.setText(info);
    }

    /** 设置时间 */
    public void setTime(String time) {
        mTvLogisticsTime.setText(time);
    }
}
